package f.h.dragon.luceneInAction.test;

import junit.framework.TestCase;
import static f.h.dragon.util.OutUtil.*;

import org.apache.log4j.Logger;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.TermQuery;

/**
 * QueryTester: test utilities
 * 
 * @author Wenlong Meng(wenlong.meng@gmail.com)
 * @version 1.0 at 2012/04/12
 * @since 1.0
 */
public class QueryTester extends TestCase {
	
	//local variables
	/**
	 * logger
	 */
	private static Logger logger = Logger.getLogger(QueryTester.class);
	
	/**
	 * init...
	 * 
	 * @see junit.framework.TestCase#setUp()
	 */
	@Override
	protected void setUp() throws Exception {
		super.setUp();
	}
	
	/**
	 * destroy...
	 * @see junit.framework.TestCase#tearDown()
	 */
	@Override
	protected void tearDown() throws Exception {
		super.tearDown();
	}
	
	/**
	 * 多线程测试
	 */
	public static void testMutilSearchUsers(){
		BooleanQuery bq = new BooleanQuery();
		BooleanQuery bq1 = new BooleanQuery();
		BooleanQuery bq2 = new BooleanQuery();
		bq1.add(new TermQuery(new Term("id","111")), Occur.MUST);
		bq2.add(new TermQuery(new Term("name","222")), Occur.MUST_NOT);
		bq.add(new TermQuery(new Term("id","111")), Occur.SHOULD);
		bq.add(bq1, Occur.MUST);
		bq.add(bq2, Occur.MUST);
		outln(bq.toString());
	}
	
}
